<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<%@ page import="model.SuShe"%>
<%@ page import="dao.SuSheDao"%>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>

<%
	//检查会话中是否有 "fdy" 属性
	Object fdyObj = session.getAttribute("fdy");
	if (fdyObj == null) {
	    response.sendRedirect("../view/Login.jsp");
	    return;
	}
%>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>辅导员页面</title>
<link href="../css/Utils.css" rel="stylesheet" type="text/css" />
<link href="../css/List.css" rel="stylesheet" type="text/css" />
<!-- 功能列表 -->
<link rel="stylesheet" href="../css/WeiGuilist.css">
<!-- 退出登录专用 -->
   <script type="text/javascript" src="../view/Loginout.js"></script>
</head>
<body>

<!-- 头部 -->
<div class="header" ><br>
<nerong>&nbsp;&nbsp;辅导员页面&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;</nerong>
<%
 		List<String> idclassa = (List<String>)session.getAttribute("fdy");
 		String id = idclassa.get(0);
    
 			%>
 	<button onclick="confirmLogout('<%= id %>','fdy')">退出登录</button>
</div><br>

<div class="left" >
<table width="80%" height="80%">
<th>
<nerong>辅导员可选择内容</nerong>

</th>
<tr>
<td>
<a href="../View_Msg/msgFdy.jsp">&emsp;个人信息</a><br>
</td>
</tr>

<tr>
<td>
<a href = "../View_SuShe/SuSheFDY_List.jsp">&emsp;学生宿舍信息查询</a><br>
</td>
</tr>
<tr>

<td>
<a href = "../View_WeiGui/WeiGuiFDY.jsp">&emsp;宿舍违规信息查询</a><br>

</td>
</tr>

<tr>
<td>
<a href = "../View_leave/T_leave.jsp">&emsp;请假信息处理</a><br>
</td>
</tr>

</table>

</div>



<div class="context" >
<!-- 这部分是每个大功能的小功能 -->
 <h2>学生宿舍列表</h2>
		<table class="Alltable" border="1">
        <thead>
            <tr>
                <th>学号</th>
                <th>班级</th>
                <th>姓名</th>
                <th>宿舍号</th>
                <th>规格</th>
                <th>配额</th>
            </tr>
        </thead>
        <tbody>
            <%
            // 获取当前页（默认第一页）
            int currentPage = 1;
            int pageSize = 10;  // 每页显示5条记录
            String pageParam = request.getParameter("page");
            ArrayList<String> idclass = (ArrayList<String>)session.getAttribute("fdy");
            
            if (pageParam != null && !pageParam.isEmpty()) {
                currentPage = Integer.parseInt(pageParam);
            }
            SuSheDao dao = new SuSheDao();
            SuShe ss =new SuShe();
                // 获取总记录数
                int totalUsers = dao.getSSFDYCount(idclass);
                // 计算总页数
                int totalPages = (int) Math.ceil((double) totalUsers / pageSize);
                // 获取当前页的数据
                List<SuShe> wgs = dao.getSSFDYPage(idclass,currentPage, pageSize);
                for (SuShe wg : wgs) {
            %>
            <tr>
                <td><%= wg.getStudentId() %></td>
                <td><%= wg.getStudentClass() %></td>
                <td><%= wg.getStudentName() %></td>
                <td><%= wg.getRoomid() %></td>
                <td><%= wg.getQuota() %></td>
                <td><%= wg.getGuige() %></td>
             	
            </tr>
            
            <%
                
                }
            %>
           
           	
            
        </tbody>
    </table>
     <!-- 分页显示 -->
    
        <% if (currentPage > 1) { %>
            <a href="SuSheFDY_List.jsp?page=<%= currentPage - 1 %>">上一页</a>
        <% } %>
        <span>页 <%= currentPage %> / <%= totalPages %></span>
        <% if (currentPage < totalPages) { %>
            <a href="SuSheFDY_List.jsp?page=<%= currentPage + 1 %>">下一页</a>
        <% } %>
    
</div>

</body>
</html>